#include "ODN_InputDevice.h"

namespace ouden {

void IInputDevice::update()
{
	
	captureInput();
	
	for (int i=0;i<m_pInputReceivers.size();++i) {
		
		//TODO: Possibly split input receivers into buffered and 
		// unbuffered
		m_pInputReceivers[i]->onUnBufInput(this);
		
	}
	
}

//Call this to inform all InputReceivers when a key is pushed down
void IInputDevice::informKeyDown(KeyCode iKey)
{
	for (int i=0;i<m_pInputReceivers.size();++i) {
		assert(m_pInputReceivers[i]);
		m_pInputReceivers[i]->onKeyDown(iKey);
	}
}
//Call this to inform all InputReceivers when a key is released
void IInputDevice::informKeyUp(KeyCode iKey)
{
	for (int i=0;i<m_pInputReceivers.size();++i) {
		m_pInputReceivers[i]->onKeyUp(iKey);
	}
}
//Call this to inform all InputReceivers when a key is pressed and released
void IInputDevice::informKeyPress(KeyCode iKey)
{
	for (int i=0;i<m_pInputReceivers.size();++i) {
		m_pInputReceivers[i]->onKeyPress(iKey);
	}
}

//Call this to inform all InputReceivers when the mouse is moved
void IInputDevice::informMouseMove(Vector vPos, MouseButton iButtonState)
{
	
	for (int i=0;i<m_pInputReceivers.size();++i) {
		m_pInputReceivers[i]->onMouseMove(vPos, iButtonState);
	}
	
}

//Call these to inform all InpurReceivers when a mouse button event occurs
void IInputDevice::informMouseButtonDown(Vector vPos, MouseButton iButton)
{
	
	for (int i=0;i<m_pInputReceivers.size();++i) {
		m_pInputReceivers[i]->onMouseButtonDown(vPos, iButton);
	}
	
}
void IInputDevice::informMouseButtonUp(Vector vPos, MouseButton iButton)
{
	
	for (int i=0;i<m_pInputReceivers.size();++i) {
		m_pInputReceivers[i]->onMouseButtonUp(vPos, iButton);
	}
	
}
void IInputDevice::informMouseButtonPress(Vector vPos, MouseButton iButton)
{
	
	for (int i=0;i<m_pInputReceivers.size();++i) {
		m_pInputReceivers[i]->onMouseButtonPress(vPos, iButton);
	}
	
}

} //namespace ouden
